import request from 'src/axios'

/**
 * @description 分页查询菜单
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const pageMenu = (params: object) => {
  return request.get('/system/menu/page', { params })
}

/**
 * @description 查询所有可用菜单
 * @param { Object } params 查询参数
 * @returns Promise
 */
export const listMenu = (params?: object) => {
  return request.get('/system/menu/list', { params })
}

/**
 * @description 查看菜单
 * @param { String } id 主键
 * @returns Promise
 */
export const viewMenu = (id: string) => {
  return request.get('/system/menu', { params: { id } })
}

/**
 * @description 新增菜单
 * @param { Object } data 新增数据
 * @returns Promise
 */
export const saveMenu = (data: object) => {
  return request.post('/system/menu', data)
}

/**
 * @description 修改菜单
 * @param { Object } data 修改数据
 * @returns Promise
 */
export const updateMenu = (data: object) => {
  return request.put('/system/menu', data)
}

/**
 * @description 删除菜单
 * @param { Array<string> } ids 主键数组
 * @returns Promise
 */
export const deleteMenu = (ids: Array<string>) => {
  return request.delete('/system/menu', { data: ids })
}

/**
 * @description 启用菜单
 * @param { String } id 主键
 * @returns Promise
 */
export const enableMenu = (id: string) => {
  return request.put('/system/menu/enable', { id })
}

/**
 * @description 禁用菜单
 * @param { String } id 主键
 * @returns Promise
 */
export const disableMenu = (id: string) => {
  return request.put('/system/menu/disable', { id })
}
